<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="${ctxPath}/assets/expand/images/favicon.ico" rel="icon">
    <title>${constants.getSystemName()}</title>
    <link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css?v=${constants.getReleaseVersion()}"/>
</head>

<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">

    <!-- 头部 -->
    @include("/common/_header.html"){}

    <!-- 侧边栏 -->
    @include("/common/_sidebar.html"){}

    <!-- 主体部分 -->
    @include("/common/_body.html"){}

    <!-- 底部 -->
    @include("/common/_footer.html"){}

</div>
<!-- 加载动画，移除位置在common.js中 -->
@include("/common/loading.html"){}

@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "${ctxPath}",
        version: '${constants.getReleaseVersion()}'
    };
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>

<script>
    layui.use(['layer', 'element', 'admin', 'index', 'ax','form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;
        var index = layui.index;
        var $ax = layui.ax;
        var form = layui.form;

        // 默认加载主页
        index.loadHome({
            menuPath: $("#firstPageAction").attr('lay-href'),
            menuName: '<i class="layui-icon layui-icon-home"></i>'
        });

        // var first_denglu = sessionStorage.getItem("first_denglu");
        // if(first_denglu==undefined){
        //     admin.open({
        //         id: 'pswForm',
        //         type: 2,
        //         title: '版本切换',
        //         shade: 0,
        //         content: '${ctxPath}/system/version_qiehuan'
        //     });
        //     sessionStorage.setItem("first_denglu","1");
        // }

        // 版本更新
        $('#tip').on('click', function () {
            admin.open({
                type: 1
                ,btn: ['确定'],
                btnAlign: 'c',
                title:'版本更新',
                content: $('#id') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            });
        });

        // 版本更新
        var ajax = new $ax(Feng.ctxPath + "/weiXinApi/versionList", function (res) {
            // for (var i = 0; i < res.data.length; i++) {
            //     $("#tip_ol").append('<li>' + res.data[i].content + '</li>');
            // }
            if(!res.data.noticeId) return
            let lastNotice = layui.data('lastNotice')
            let tempContent =  res.data.content.replace(/\n/g,'<br>')

            $("#tip_ol").html('<div>' + tempContent + '</div> ')
            // $("#update_time").append('<span>' +res.data.createTime + '</span>')
            $("#update_time").append('<span>' + (res.data.createTime).substring(0,11) + '</span>')
            $('#update_cont').append('<span>'+ res.data.title +'</span>')

            if (lastNotice.id != res.data.noticeId || !lastNotice) {
                $('#tip').trigger('click')
                layui.data('lastNotice', {
                    key: 'id',
                    value: res.data.noticeId
                })
            }
            form.render();
        })
        ajax.start();




        // 修改密码点击事件
        $('#setPsw').click(function () {
            admin.open({
                id: 'pswForm',
                type: 2,
                title: '修改密码',
                shade: 0,
                content: '${ctxPath}/system/user_chpwd'
            });
        });

        // 退出登录点击事件
        $('#btnLogout').click(function () {
            var ajax = new $ax(Feng.ctxPath + "/logout", function (data) {
                Feng.success("退出成功!");
                window.location.href = Feng.ctxPath + "/";
            }, function (data) {
                layer.msg("退出失败！" + data.responseJSON.message, {icon: 5, anim: 6});
            });
            ajax.start();
        });


        $(function () {
            var version = localStorage.getItem("version");
            if(version == undefined){
                $('#bb').text("切换新版本")
            }else if (version == 1){
                $('#bb').text("切换新版本")
            }else if (version == 2){
                $('#bb').text("切换旧版本")
            }
        });


        $('#version').click(function () {
            var version = localStorage.getItem("version");
            if(version == undefined){
                version = "1";
            }else if (version == 1){
                version = "2";
            }else if (version == 2){
                version = "1";
            }
            localStorage.setItem('version',version);
            index.clearTabCache();
            window.location.href = Feng.ctxPath + "/?version=" + version;
        });
    });
</script>
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?0e8c3239c13edae0500332bfee182e6f";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</body>

</html>